package com.yuw.control;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * webservlet注解需要制定 value或者initParams  两个参数中的一个，
 * 用于表示请求的映射路径
 */
@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        // 获取表单数据
        String strUserName = request.getParameter("userName");
        String strUserPsw = request.getParameter("userPsw");
        System.out.println("用户名：" + strUserName);
        // 将用户名缓存到session
        request.getSession().setAttribute("loginedUserName",strUserName);
        // 转发到结果视图页面
        request.getRequestDispatcher("logined.jsp").forward(request,response);
        // 重定向到结果视图


    }
}
